<?php

    include('connection_db.php');
    
    
    function ChargerProfil($id){	
	
		$bdd = db_connect();
		$request = $bdd->query('SELECT * FROM users WHERE id ='.$id);
                
                return $request->fetch();    
    }
    
    function connexion($login,$mdp){
                $bdd = db_connect();
		$request = $bdd->query('SELECT * FROM users WHERE mail = \''.$login.'\' AND password = \''.$mdp.'\'');
                
                $result=$request->fetch();
                    
                if($result){
                    session_start();
                    
                    $_SESSION['id']=$result['id'];
                    $_SESSION['mail']=$result['mail'];
                    $_SESSION['name']=$result['name'];
                    
                    return $result;
                    
                }
                
                return false;
        
    }
    
    function log_out(){
            session_start();
            session_destroy();
//                if($_SESSION)
//                foreach($_SESSION as $id=>$value)
//                    unset($_SESSION[$id]);
        
    }
    
?>
